﻿@model Kojarskiy.Core.SmtpSettings
@{
    ViewBag.Title = "Настройки SMTP";   
}

<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@Html.ActionLink("Администрирование", "Index", "Admin") | @ViewBag.Title 
<div style="clear: both;"></div>

@using (Html.BeginForm("SmtpSettings", "Admin", FormMethod.Post))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>@ViewBag.Title</legend>

        <table class="table table-hover">
            <tr>
                <td style="width: 20%">
                    <div style="text-align: left;">Хост</div>
                </td>
                <td>
                    <div class="text wide">
                        @Html.TextBoxFor(model => model.SmtpHost, new {@class = "form-control" })
                        @Html.ValidationMessageFor(model => model.SmtpHost)
                    </div>
                </td>
                <td colspan="2">
                    <div style="text-align: left;" onclick="SelectCridentials();">
                        @Html.CheckBoxFor(model => model.UseDefaultCredentials)  
                        Аутентификация по умолчанию</div>
                </td>
            </tr>
            <tr>
                <td style="width: 20%">
                    <div style="text-align: left;">Порт</div>
                </td>
                <td>
                    <div class="text wide">
                        @Html.TextBoxFor(model => model.SmtpPort, new {@class = "form-control" })
                    </div>
                </td>
                <td colspan="2" style="padding-left: 30px;">
                    <div>
                        Пользователь
                    </div>
                    <div class="wide">
                        @Html.TextBoxFor(model => model.SmtpUser, new {@class = "form-control" })
                        @Html.ValidationMessageFor(model => model.SmtpUser)
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <div class="header" style="text-align: left;">@Html.EditorFor(model => model.EnableSsl) Включить SSL</div>
                </td>
                <td colspan="2" style="padding-left: 30px;">
                    <div>
                        Пароль
                    </div> 
                    <div class="wide">
                        @Html.TextBoxFor(model => model.SmtpPassword, new {@class = "form-control" })
                        @Html.ValidationMessageFor(model => model.SmtpPassword)    
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <div class="header" style="text-align: left;">Email админа</div>
                </td>
                <td>
                    <div class="wide">
                        @Html.TextBoxFor(model => model.AdminEmail, new {@class = "form-control" })
                        @Html.ValidationMessageFor(model => model.AdminEmail)    
                    </div> 
                </td>
                <td colspan="2">
    
                </td>
            </tr>
        </table>
    </fieldset>

    <div class="form-actions">
        <button type="submit" class="btn btn-success">Сохранить</button>   
    </div>

}
    
<script type="text/javascript">
    
    function SelectCridentials() 
    {
        if ($("#UseDefaultCredentials").attr('checked')) 
        {
            $("#SmtpUser").attr('disabled', 'disabled');
//            $("#SmtpUser").val('');
            $("#SmtpPassword").attr('disabled', 'disabled');
//            $("#SmtpPassword").val('');
        }
        else {
            $("#SmtpUser").attr('disabled', '');
            $("#SmtpPassword").attr('disabled', '');         
        }
    }
</script>
